// Author  : Morbid
// Time    : 2022/04/30 20:27
// FileName: Main_183.java
// Software: IntelliJ IDEA

package LeetCode;

public class Main_183 {
    //883. 三维形体投影面积
    static int projectionArea(int[][] grid) {
        int x = 0, y = 0, z = 0;
        for (int i = 0; i < grid[0].length; i++) {
            int tem = 0;
            for (int[] ints : grid) {
                if (ints[i] > tem)
                    tem = ints[i];
                if (ints[i] != 0)
                    z++;
            }
            x += tem;
        }
        for (int[] ints : grid)
            y += max(ints);
        return x + y + z;
    }

    //获取最大值
    static int max(int[] list) {
        int max = 0;
        for (int i : list)
            if (max < i)
                max = i;
        return max;
    }

    public static void main(String[] args) {
        int[][] grid = {{1, 2}, {3, 4}};
        System.out.println(projectionArea(grid));
    }

}
